package com.ww.learn.oop.sam

/**
 * SAM接口的柯里化
 */

fun interface CurriedFunction<A, B, R> {
    fun invoke(a: A): (B) -> R
}

fun main() {
    val add: CurriedFunction<Int, Int, Int> = CurriedFunction { a: Int ->
        { b: Int -> a + b }
    }

    val add5 = add.invoke(5)
    println(add5.invoke(10))  // 输出: 15
    println(add5(10))         // 输出: 15
}